//
//  PopoverViewController.swift
//  SinaWeibo
//
//  Created by 胡阳 on 16/5/20.
//  Copyright © 2016年 young4ever. All rights reserved.
//

import UIKit

let cellID = "popover_cell"

class PopoverViewController: UIViewController {

    @IBOutlet weak var tableView: UITableView!
    
    var delegate:AnyObject?
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    private lazy var dataArray:[String] = {
    
        let array = ["football", "basketball", "baseball", "tennis", "ice hockey", "badminton"]
        return array
    }()
}

extension PopoverViewController: UITableViewDelegate, UITableViewDataSource {

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataArray.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        var cell = tableView.dequeueReusableCellWithIdentifier(cellID);
        
        if cell == nil {
            cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: cellID)
        }
        
        cell?.textLabel?.textAlignment = NSTextAlignment.Center
        cell?.textLabel?.textColor = UIColor.darkGrayColor()
        cell?.textLabel?.text = dataArray[indexPath.row]
        
        return cell!
    }

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        print(#function)
    }
}
